// pages/protocol/protocol.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    text:""
  },
// 同意协议
agree:function(){
  var pages = getCurrentPages();
  var currPage = pages[pages.length - 1]; //当前页面
  var prevPage = pages[pages.length - 2]; //上一个页面

  prevPage.setData({
    check: true
  });
  wx.navigateBack({
    
  })

},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    if (options.protocol== 1){
      wx.request({
        url: 'https://www.xiaozheng8.com/receiveAgreement',
        data: 'sendAgreement',
        method: 'post',
        success: function (res) {
          console.log(res);
          that.setData({
            text: res.data
          })
          console.log(that.data.text)
          that.data.text.replace(/\s\s/g, "&emsp;&emsp;");
          console.log(that.data.text)
          that.data.text = that.data.text.replace(/&emsp;/g, "&nbsp;&nbsp;");
          console.log(that.data.text);
          that.setData({
            text:that.data.text
          });
          console.log(that.data.text)
        },
        fail: function (res) { },
        complete: function (res) { },
      })
    }else{
      wx.request({
        url: 'https://www.xiaozheng8.com/sendAgreement',
        data: 'receiveAgreement',
        method: 'post',
        success: function (res) {
          console.log(res);
          that.setData({
            text: res.data
          })
         that.data.text= that.data.text.replace(/ /g, "&emsp;");
          that.data.text = that.data.text.replace(/&emsp;/g, "&nbsp;&nbsp;");
         that.setData({
           text:that.data.text
         })
          console.log(that.data.text)
          // that.data.text.replace(/\t/g, "1111");
          that.setData({
            text: that.data.text
          })
          console.log(that.data.text);
        },
        fail: function (res) { },
        complete: function (res) { },
      })
    }
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})